const { defineConfig } = require('@vue/cli-service')

module.exports = defineConfig({
  transpileDependencies: true,
  devServer: {
    port: 5173,
    open: true,
    host: 'localhost',
    proxy: {
      '/api': {
        target: 'http://localhost:8080',
        changeOrigin: true,
        secure: false,
        // 不要重写路径，因为后端context-path就是/api
        onProxyReq: (proxyReq, req, res) => {
          console.log(
            '代理请求：',
            req.method,
            req.url,
            ' -> ',
            proxyReq.getHeader('host') + proxyReq.path
          )
        },
        onProxyRes: (proxyRes, req, res) => {
          console.log('代理响应：', proxyRes.statusCode, req.url)
        },
        onError: (err, req, res) => {
          console.log('代理错误：', err)
        }
      }
    }
  },
  lintOnSave: false
}) 